/*
 *	Filename: Quadrotor_Mpu6050.h
 *	Fuction: Header File
 *	Modified: 2016-11-09
 *	Author: Bin
 */

#ifndef QUADROTOR_MPU6050_H
#define QUADROTOR_MPU6050_H

#define MAX_WAIT_TIME 100		//Time for Waiting I2c Communication (us)
#define PI 3.14

#define	SMPLRT_DIV		0x19	//陀螺仪采样率，典型值：0x07(125Hz)
#define	CONFIG			0x1A	//低通滤波频率，典型值：0x06(5Hz)
#define	GYRO_CONFIG		0x1B	//陀螺仪自检及测量范围，典型值：0x18(不自检，2000deg/s)
#define	ACCEL_CONFIG	0x1C	//加速计自检、测量范围及高通滤波频率，典型值：0x01(不自检，2G，5Hz)
#define	ACCEL_XOUT_H	0x3B
#define	ACCEL_XOUT_L	0x3C
#define	ACCEL_YOUT_H	0x3D
#define	ACCEL_YOUT_L	0x3E
#define	ACCEL_ZOUT_H	0x3F
#define	ACCEL_ZOUT_L	0x40
#define	TEMP_OUT_H		0x41
#define	TEMP_OUT_L		0x42
#define	GYRO_XOUT_H		0x43
#define	GYRO_XOUT_L		0x44
#define	GYRO_YOUT_H		0x45
#define	GYRO_YOUT_L		0x46
#define	GYRO_ZOUT_H		0x47
#define	GYRO_ZOUT_L		0x48
#define	PWR_MGMT_1		0x6B	//电源管理，典型值：0x00(正常启用)
#define	WHO_AM_I		0x75	//IIC地址寄存器(默认数值0x68，只读)
#define	MPU6050_ADDRESS	0x68	//IIC写入时的地址字节数据

// Struct Type Definitions
struct Mpu6050Data {
	float32 ACC_X;	// Acceleration of X Axis
	float32 ACC_Y;	// Acceleration of Y Axis
	float32 ACC_Z;	// Acceleration of Z Axis
	float32 GYR_X;	// Angular velocity of X Axis
	float32 GYR_Y;	// Angular velocity of Y Axis
	float32 GYR_Z;	// Angular velocity of Z Axis
	float32 Roll;	// Roll Angle
	float32 Pitch;	// Pitch Angle
};

// Prototype statements for functions in Quadrotor_Mpu6050.c
extern void InitI2cGpio(void);
extern void InitI2c(void);
extern Uint16 I2cWrite(Uint16 addr, Uint16 data);
extern Uint16 I2cRead(Uint16 addr, Uint16 *pData);
extern Uint16 writeMpu6050(Uint16 regAddr, Uint16 data);
extern Uint16 readMpu6050(Uint16 regAddr, Uint16 *pData);
extern Uint16 InitMpu6050(void);
extern Uint16 getSensor(struct Mpu6050Data *p);

#endif
